package cn.edu.cdu.farmdeal.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * @Author: tupeng
 * @Date: 2020/3/11
 **/
@Controller
//@RequestMapping("/")
public class freetest {

    @Autowired
    private resource resource;

    @RequestMapping("/test")
    public ModelAndView add(ModelAndView map, HttpServletRequest request){
        HttpSession session1 = request.getSession();
        String name= resource.getName();
        session1.setAttribute("username","tupeng");
        map.addObject("resource",name);
        map.setViewName("index");
        System.out.println(resource.getName());
        return map;
    }
}
